from django import http
from django.contrib.auth.mixins import LoginRequiredMixin

from utils.response_code import RETCODE


class LoginRequiredJSONMixinView(LoginRequiredMixin):
    """重写LoginRequiredMixin 让它返回的不是重定向 而是json格式"""

    def handle_no_permission(self):
        return http.JsonResponse({'code': RETCODE.SESSIONERR, 'errmsg': '用户未登录'})
